package com.thf.controller;

import com.alibaba.fastjson.JSON;
import com.thf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;


@Controller
public class UserGetCountController{

    @Autowired
    private  UserService userService ;

    @RequestMapping("/back/user/count")
    @ResponseBody
    protected Integer userGetCount(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        Integer count = null ;
        //-返回值
            String val = req.getParameter("val");
            Map map = JSON.parseObject(val,Map.class);
            count = userService.getCount(map);
//       反馈给前端--返回值
//        resp.getWriter().println(count);
        return count ;
    }
}
